{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-form toolbar">
            <div class="layui-form-item">
                <form action="{:request()->url()}" class="layui-form" method="get">
                <div class="layui-inline" style="padding-left: 0px;">
                    <a href="{:url('user/customer/add')}" class="layui-btn ajax-iframe" data-width="1010px" data-height="590px"><i class="fa fa-plus-circle"></i> 新增客户</a>
                    <a href="{:url('user/customer_config/index')}" class="layui-btn ajax-iframe" data-width="800px" data-height="570px"><i class="fa fa-cog"></i> 参数设置</a>
                </div>
                
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">关键字：</label>
                    <div class="layui-input-inline mr0">
                        <input name="keywords" class="layui-input" type="text" placeholder="请输入名称、电话、区域"/>
                    </div>
                </div>
                
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">分类：</label>
                    <div class="layui-input-inline mr0">
                        <select name="classify">
                            <option value="">请选择</option>
                            {foreach name=":get_customer_config('classify')" item="v"}
                            <option value="{$v.id}" {if condition="isset($data) and input('classify') eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">状态：</label>
                    <div class="layui-input-inline mr0">
                        <select name="status">
                            <option value="">请选择</option>
                            {foreach name=":get_customer_config('status')" item="v"}
                            <option value="{$v.id}" {if condition="isset($data) and input('status') eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline form-search-show-expand">
                    <label class="layui-form-label w-auto">来源：</label>
                    <div class="layui-input-inline mr0">
                        <select name="comefrom">
                            <option value="">请选择</option>
                            {foreach name=":get_customer_config('comefrom')" item="v"}
                            <option value="{$v.id}" {if condition="isset($data) and input('comefrom') eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline form-search-show-expand">
                    <label class="layui-form-label w-auto">星级：</label>
                    <div class="layui-input-inline mr0">
                        <select name="star">
                            <option value="">请选择</option>
                            <option value="1" {if condition="isset($data) and input('star') eq '★'"}selected="selected"{/if}>★</option>
                            <option value="2" {if condition="isset($data) and input('star') eq '★★'"}selected="selected"{/if}>★★</option>
                            <option value="3" {if condition="isset($data) and input('star') eq '★★★'"}selected="selected"{/if}>★★★</option>
                            <option value="4" {if condition="isset($data) and input('star') eq '★★★★'"}selected="selected"{/if}>★★★★</option>
                            <option value="5" {if condition="isset($data) and input('star') eq '★★★★★'"}selected="selected"{/if}>★★★★★</option>
                        </select>
                    </div>
                </div>
                {if $action !='my_customer'}
                <div class="layui-inline form-search-show-expand">
                    <label class="layui-form-label w-auto">用户：</label>
                    <div class="layui-input-inline mr0">
                        <select name="user_id">
                            <option value="">请选择</option>
                            {foreach name=":\app\user\model\User::get_lists();" item="v"}
                            <option value="{$v.id}" {if condition="isset($data) and input('user_id') eq $v.id"}selected="selected"{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                {/if}
                    
                <div class="layui-inline" style="padding-left: 20px;">
                    <button class="layui-btn layui-btn-primary ajax-search"><i class="fa fa-search"></i> 搜索</button>
                    <a class="layui-btn layui-btn-primary form-search-expand" data-expand="true">
                        展开 <i class="layui-icon layui-icon-down"></i>
                    </a>
                </div>
                </form>
            </div>
        </div>
        <div class="layui-btn-group">
            
        </div>
        <table class="layui-table layui-form">
            <thead>
                <tr>
                    <th>头像</th>
                    <th>客户信息</th>
                    <th>区域</th>
                    <th>分类</th>
                    <th>来源</th>
                    <th>状态</th>
                    <th>最后更新时间</th>
                    <th>用户</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="list" item="v" empty="$empty"}
                <tr>
                    <td><img src="{$v.avatar}" class="tdImg" tb-img width="60" height="60"/></td>
                    <td>
                        <b>{$v.name}</b>
                        <br>{$v.mobile}
                        <br>{$v.star}
                    </td>
                    <td>{$v.province}/{$v.city}/{$v.area}</td>
                    <td>{$v.classify_name}</td>
                    <td>{$v.comefrom_name}</td>
                    <td>{$v.status_name}</td>
                    <td>{$v.update_time}</td>
                    <td>{$v.user.name}</td>
                    <td>
                        <a href="{:url('user/customer/detail', ['id' => $v.id])}" class="layui-btn layui-btn-sm layui-btn-normal ajax-detail"><i class="fa fa-tv"></i> 详情</a>
                        <a href="{:url('user/customer/edit', ['id' => $v.id])}" data-width="1010px" data-height="590px" class="layui-btn layui-btn-sm layui-btn-normal ajax-iframe"><i class="fa fa-edit"></i> 编辑</a>
                        <a href="{:url('user/customer/del', ['id' => $v.id])}" class="layui-btn layui-btn-sm layui-btn-danger ajax-delete"><i class="fa fa-trash-o"></i> 删除</a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
        <div class="page">{$list|raw}</div>
    </div>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['layer', 'table', 'util'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;
        var util = layui.util;

        // 点击图片放大
        $(document).off('click.tbImg').on('click.tbImg', '[tb-img]', function () {
            layer.photos({photos: {data: [{src: $(this).attr('src')}]}, shade: .1, closeBtn: true});
        });

    });
</script>
{/block}